/*
 * @FilePath: /fxfzywpt/src/store/modules/arcMap.js
 * @Description:
 */
import { ArcgisService } from '@/map/ArcgisService';
const useArcMapDataStore = defineStore('useArcMapDataStore', {
  state: () => ({
    feature1: null,
    feature2: null,
    feature3: null,
    feature4: null,
    featureMap: null,
    type: ['全新世断层', '晚更新世断层', '早中更新世断层', '前第四纪断层'],
  }),
  getters: {
    getAllArcMapData: (state) => {
      return state.featureMap;
    },
  },
  actions: {
    async getAllArcData() {
      this.featureMap = new Map();
      let arcgisService = new ArcgisService({});
      for (let i = 0; i < this.type.length; i++) {
        const name = this.type[i];
        let prom = await arcgisService.showArcgisHddcLayer(name);
        console.log('prom', prom);
        let layer = prom.get(name);
        this.featureMap.set(name, layer);
      }
      console.log('featuremap', this.featureMap);
      return new Promise((resolve) => {
        resolve(this.featureMap);
      });
    },
  },
});

export default useArcMapDataStore;
